package com.semeureka.fault.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.semeureka.fault.bean.Device.Phase;
import com.semeureka.fault.bean.Warn.WarnType;
import com.semeureka.fault.util.Message;

@Entity
@Table(name = "T_PDXL_POINT")
public class Point {
	private static final WarnType[] WarnTypes = WarnType.values();
	private static final Phase[] Phases = Phase.values();
	@Id
	@GeneratedValue
	private Long id;
	@Column(name = "POINT_CONTENT")
	private byte[] content; // number, phase, warnType
	@Column(name = "POINT_VALUE")
	private byte[] value;
	@Column(name = "POINT_TYPE")
	private Integer type;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public byte[] getContent() {
		return content;
	}

	public void setContent(byte[] content) {
		this.content = content;
	}

	public byte[] getValue() {
		return value;
	}

	public void setValue(byte[] value) {
		this.value = value;
	}

	/**
	 * 要和{@link Group#getType()}相匹配，更多信息参考{@link Group#getType()}、
	 * {@link Message#GT_GPRS}和{@link Message#GT_P101}
	 */
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public int getNumber() {
		return (int) content[0];
	}

	public Phase getPhase() {
		return Phases[content[1]];
	}

	public WarnType getWarnType() {
		return WarnTypes[content[2]];
	}

	public boolean isCurrent() {
		// TODO Auto-generated method stub
		return false;
	}
}
